package com.sxu.spring_ioc.controller;

import com.sxu.spring_ioc.component.UserComponent;
import com.sxu.spring_ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class HelloController {
    @Autowired
    private UserService userService;
//    private UserComponent userComponent;

    //构造注入
//    public HelloController() {}
//
//    public HelloController(UserService userService) {
//        this.userService = userService;
//    }
//
//    @Autowired
//    public HelloController(UserService userService,UserComponent userComponent) {
//        this.userService = userService;
//        this.userComponent = userComponent;
//    }

    //Setter注入
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }
    public void sayHi() {
        userService.doService();
        System.out.println("hi,use Controller....");
    }
}

